package com.ficus.road.maintain.util;

import org.apache.commons.lang3.RandomUtils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;

public class IdGeneratorUtil {

    private static SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");

    /**
     * id 生成器
     *
     * @return
     */
    public static String generatorId() {
        int i = RandomUtils.nextInt(10, 99);
        String id = sdf.format(new Date()) + i;
        return id;
    }

    public static void main(String[] args) {
//        String format = sdf.format(new Date());
//        System.out.println(format);
        System.out.println(getUUID());
    }

    public static String getUUID() {
        UUID uuid = UUID.randomUUID();
        String str = uuid.toString();
        String uuidStr = str.replace("-", "");
        return uuidStr;
    }
}
